<?php
/**
 * $Id: gallery.php 180 2010-09-06 08:10:39Z shrey $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * This is parent of parent class of a controller and should not be edited ever without permission.
 * @version 			$Rev: 180 $
 * @lastModifiedBy		$LastChangedBy: shrey $
 * @lastChanged			$Date: 2010-09-06 13:40:39 +0530 (Mon, 06 Sep 2010) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */

/**
 * Gallery helper for attractive display of collection of assets in no time.
 * Study carefully to properly use it. Implementation is done in gallery views file.
 * Known Issues: Can not display 2 galleries at a time on one page.
 *
 */
class GalleryHelper extends AppHelper {
	
	var $helpers = array('Html','Assets.Asset');
	
	var $columns = 4;
	var $title = "Gallery";
	var $galleryItems = array();
	var $options = array();
	var $imgOptions = array();
	var $galleryElement = 'gallery';
	var $showTitle = true;
	var $model  = null;
	
	/**
	 * Set no. of columns to show in gallery
	 *
	 * @param unknown_type $columns
	 */
	function setColumns($columns)
	{
		$this->columns = $columns;
	}
	
	/**
	 * Set gallery title. If not set default title "Gallery" will be appeared
	 *
	 * @param unknown_type $title
	 */
	function setTitle($title)
	{
		$this->title = $title;
	}
	
	/**
	 * Set gallery items which is fetched by model, and it will take care of rest
	 *
	 * @param unknown_type $galleryItems
	 */
	function setGalleryItems($galleryItems)
	{
		$this->galleryItems = $galleryItems;
	}
	
	/**
	 * Used to set image options like class/effects etc. More options to be added soon
	 *
	 * @param unknown_type $options
	 */
	function setImageOptions($options = array())
	{
		$this->imgOptions = $options;
	}
	/**
	 * 
	 * @param $options
	 * @return unknown_type
	 */
	function setOptions($options)
	{
		$this->options = $options;
	}
	/**
	 * This lets you set some very attractive Web2'ish elements for gallery display
	 *
	 * @param unknown_type $name
	 */
	function setGalleryElement($name)
	{
		$this->galleryElement = $name;
	}
	
	/**
	 * Outputs code to the view, after all above options are set
	 *
	 * @return unknown
	 */
	function output()
	{
		if(!$this->model)
			trigger_error("No model selected");
		$view = ClassRegistry::getObject('View');
		$output = $view->renderElement($this->galleryElement, array('columns'=>$this->columns, 'title'=>$this->title, 'galleryItems'=>$this->galleryItems, 'imgOptions'=>$this->imgOptions, 'showTitle'=>$this->showTitle,'options'=>$this->options,'model'=>$this->model));
		return $output;
	}
	
	/**
	 * Outputs css to the view
	 *
	 */
	function beforeRender()
	{
		$this->Html->css('/assets/css/gallery.css',false);
	}
	
	function setModel($model)
	{
		$this->model = $model;
	}
	
	
}
?>